const path = require('path')

// 加载不是图片的资源，字体、视频
const nonImageResourcesGlobs = ["../res/**/*.woff2", "../res/**/*.ttf", "../res/*.ico", "../res/**/*.webm"];
// 加载图片
const imageResourcesGlobs = ['../res/**/*.png', '../res/**/*.svg', '../res/**/*.jpg', '../res/**/*.jpeg', '../res/**/*.gif']

function gulptasksImageResources($, gulp, buildFolder){
  const resourceDestFolder = path.join(buildFolder, 'res')

  // 将构建非图片的资源导入
  gulp.task('imgres.copyNonImageResources', () => {
    return gulp
      .src(nonImageResourcesGlobs)
      .pipe($.cached('imgres.copyNonImageResources'))
      .pipe(gulp.dest(path.join(resourceDestFolder)))
  })

  // 将构建页面的图片导入
  gulp.task('imgres.copyImageResources', () => {
    return gulp
      .src(imageResourcesGlobs)
      .pipe($.cached('imgres.copyImageResources'))
      .pipe(gulp.dest(path.join(resourceDestFolder)))
  })
}

module.exports = {
  gulptasksImageResources,
  nonImageResourcesGlobs,
  imageResourcesGlobs
}